#include "statusbar.h"
#include "entry/EasyUIContext.h"

/*TAG:GlobalVariable全局变量*/
static ZKWindow* mWinSubPtr;
static ZKTextView* morderPtr;
static ZKTextView* mSub_itemPtr;
static ZKTextView* mMain_itemPtr;
static ZKButton* mButtonRightPtr;
static ZKButton* mButtonLeftPtr;
static ZKButton* mButtonDownPtr;
static ZKButton* mButtonUpPtr;
static ZKListView* mListViewBarPtr;
static ZKWindow* mWinMenuPtr;
static ZKTextView* mBurshRotationalPtr;
static ZKTextView* mSpeedPtr;
static ZKTextView* mlinePtr;
static ZKTextView* mspeedUnitPtr;
static ZKWindow* mWinSpeedPtr;
static ZKTextView* mTextLogoPtr;
static ZKTextView* mBottombgPtr;
static ZKTextView* mshiningGearPtr;
static ZKTextView* mTextView3Ptr;
static ZKTextView* mrangePtr;
static ZKTextView* moilIconPtr;
static ZKWindow* mWinFuelPtr;
static ZKTextView* mTextView4Ptr;
static ZKTextView* mtempIconPtr;
static ZKWindow* mWinCoolantPtr;
static ZKTextView* mgearPtr;
static ZKTextView* mmileageTotalPtr;
static ZKTextView* mgearRankPtr;
static ZKTextView* mcompassPtr;
static ZKTextView* mTextView1Ptr;
static ZKTextView* mWD4LOWPtr;
static ZKTextView* mECOPtr;
static ZKTextView* mdischargePtr;
static ZKTextView* mAUTOPtr;
static ZKTextView* mSERVPtr;
static ZKTextView* mLOCKPtr;
static ZKTextView* mNEUTRALPtr;
static ZKTextView* mOil_temperaturePtr;
static ZKTextView* mbrakingPtr;
static ZKTextView* mLow_oil_levePtr;
static ZKTextView* mGeneratorBatteryPtr;
static ZKTextView* msteeringSystemPtr;
static ZKTextView* mfailurePtr;
static ZKTextView* mElectronic_throttlePtr;
static ZKTextView* mAutomaticPtr;
static ZKTextView* mTrailer_malfunctionPtr;
static ZKTextView* mCleaning_liquidPtr;
static ZKTextView* mascend_descendPtr;
static ZKTextView* mFuel_tankPtr;
static ZKTextView* mOIL_PRESSUREPtr;
static ZKTextView* mAntifreezePtr;
static ZKTextView* mTextFaultPtr;
static ZKWindow* mWinFaultPtr;
static ZKTextView* mTextDoorRRPtr;
static ZKTextView* mTextDoorRLPtr;
static ZKTextView* mTextDoorFRPtr;
static ZKTextView* mTextDoorFLPtr;
static ZKTextView* mCarDoorPtr;
static ZKWindow* mWindowCarDoorPtr;
static statusbar* mstatusbarPtr;
/* register sysapp */
REGISTER_SYSAPP(APP_TYPE_SYS_STATUSBAR, statusbar);

typedef struct {
	int id; // 定时器ID ， 不能重复
	int time; // 定时器  时间间隔  单位 毫秒
}S_ACTIVITY_TIMEER;

#include "logic/statusbar.cc"


/***********/
typedef struct {
    int id;
    const char *pApp;
} SAppInfo;

/**
 *点击跳转window
 */
static SAppInfo sAppInfoTab[] = {
//  { ID_MAIN_TEXT, "TextViewActivity" },
};

/***************/
typedef bool (*ButtonCallback)(ZKButton *pButton);
/**
 * button onclick表
 */
typedef struct {
    int id;
    ButtonCallback callback;
}S_ButtonCallback;

/*TAG:ButtonCallbackTab按键映射表*/
static S_ButtonCallback sButtonCallbackTab[] = {
    ID_STATUSBAR_ButtonRight, onButtonClick_ButtonRight,
    ID_STATUSBAR_ButtonLeft, onButtonClick_ButtonLeft,
    ID_STATUSBAR_ButtonDown, onButtonClick_ButtonDown,
    ID_STATUSBAR_ButtonUp, onButtonClick_ButtonUp,
};
/***************/


typedef void (*SeekBarCallback)(ZKSeekBar *pSeekBar, int progress);
typedef struct {
    int id;
    SeekBarCallback callback;
}S_ZKSeekBarCallback;
/*TAG:SeekBarCallbackTab*/
static S_ZKSeekBarCallback SZKSeekBarCallbackTab[] = {
};


typedef int (*ListViewGetItemCountCallback)(const ZKListView *pListView);
typedef void (*ListViewobtainListItemDataCallback)(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index);
typedef void (*ListViewonItemClickCallback)(ZKListView *pListView, int index, int id);
typedef struct {
    int id;
    ListViewGetItemCountCallback getListItemCountCallback;
    ListViewobtainListItemDataCallback obtainListItemDataCallback;
    ListViewonItemClickCallback onItemClickCallback;
}S_ListViewFunctionsCallback;
/*TAG:ListViewFunctionsCallback*/
static S_ListViewFunctionsCallback SListViewFunctionsCallbackTab[] = {
    ID_STATUSBAR_ListViewBar, getListItemCount_ListViewBar, obtainListItemData_ListViewBar, onListItemClick_ListViewBar,
};


typedef void (*SlideWindowItemClickCallback)(ZKSlideWindow *pSlideWindow, int index);
typedef struct {
    int id;
    SlideWindowItemClickCallback onSlideItemClickCallback;
}S_SlideWindowItemClickCallback;
/*TAG:SlideWindowFunctionsCallbackTab*/
static S_SlideWindowItemClickCallback SSlideWindowItemClickCallbackTab[] = {
};

typedef void (*EditTextInputCallback)(const std::string &text);
typedef struct {
    int id;
    EditTextInputCallback onEditTextChangedCallback;
}S_EditTextInputCallback;
/*TAG:EditTextInputCallback*/
static S_EditTextInputCallback SEditTextInputCallbackTab[] = {
};

typedef void (*VideoViewCallback)(ZKVideoView *pVideoView, int msg);
typedef struct {
    int id; //VideoView ID
    bool loop; // 是否是轮播类型
    int defaultvolume;//轮播类型时,默认视频音量
    VideoViewCallback onVideoViewCallback;
}S_VideoViewCallback;
/*TAG:VideoViewCallback*/
static S_VideoViewCallback SVideoViewCallbackTab[] = {
};

statusbar::statusbar() {
	mVideoLoopIndex = -1;
	mVideoLoopErrorCount = 0;
}

statusbar::~statusbar() {
    // 退出应用时需要反注册
    EASYUICONTEXT->unregisterGlobalTouchListener(this);
    unregisterProtocolDataUpdateListener(onProtocolDataUpdate);
    onUI_quit();
    mstatusbarPtr = NULL;
    mWinSubPtr = NULL;
    morderPtr = NULL;
    mSub_itemPtr = NULL;
    mMain_itemPtr = NULL;
    mButtonRightPtr = NULL;
    mButtonLeftPtr = NULL;
    mButtonDownPtr = NULL;
    mButtonUpPtr = NULL;
    mListViewBarPtr = NULL;
    mWinMenuPtr = NULL;
    mBurshRotationalPtr = NULL;
    mSpeedPtr = NULL;
    mlinePtr = NULL;
    mspeedUnitPtr = NULL;
    mWinSpeedPtr = NULL;
    mTextLogoPtr = NULL;
    mBottombgPtr = NULL;
    mshiningGearPtr = NULL;
    mTextView3Ptr = NULL;
    mrangePtr = NULL;
    moilIconPtr = NULL;
    mWinFuelPtr = NULL;
    mTextView4Ptr = NULL;
    mtempIconPtr = NULL;
    mWinCoolantPtr = NULL;
    mgearPtr = NULL;
    mmileageTotalPtr = NULL;
    mgearRankPtr = NULL;
    mcompassPtr = NULL;
    mTextView1Ptr = NULL;
    mWD4LOWPtr = NULL;
    mECOPtr = NULL;
    mdischargePtr = NULL;
    mAUTOPtr = NULL;
    mSERVPtr = NULL;
    mLOCKPtr = NULL;
    mNEUTRALPtr = NULL;
    mOil_temperaturePtr = NULL;
    mbrakingPtr = NULL;
    mLow_oil_levePtr = NULL;
    mGeneratorBatteryPtr = NULL;
    msteeringSystemPtr = NULL;
    mfailurePtr = NULL;
    mElectronic_throttlePtr = NULL;
    mAutomaticPtr = NULL;
    mTrailer_malfunctionPtr = NULL;
    mCleaning_liquidPtr = NULL;
    mascend_descendPtr = NULL;
    mFuel_tankPtr = NULL;
    mOIL_PRESSUREPtr = NULL;
    mAntifreezePtr = NULL;
    mTextFaultPtr = NULL;
    mWinFaultPtr = NULL;
    mTextDoorRRPtr = NULL;
    mTextDoorRLPtr = NULL;
    mTextDoorFRPtr = NULL;
    mTextDoorFLPtr = NULL;
    mCarDoorPtr = NULL;
    mWindowCarDoorPtr = NULL;
}

const char* statusbar::getAppName() const{
    return "statusbar.ftu";
}

//TAG:onCreate
void statusbar::onCreate() {
	BaseApp::onCreate();
    mWinSubPtr = (ZKWindow*)findControlByID(ID_STATUSBAR_WinSub);
    morderPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_order);
    mSub_itemPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Sub_item);
    mMain_itemPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Main_item);
    mButtonRightPtr = (ZKButton*)findControlByID(ID_STATUSBAR_ButtonRight);
    mButtonLeftPtr = (ZKButton*)findControlByID(ID_STATUSBAR_ButtonLeft);
    mButtonDownPtr = (ZKButton*)findControlByID(ID_STATUSBAR_ButtonDown);
    mButtonUpPtr = (ZKButton*)findControlByID(ID_STATUSBAR_ButtonUp);
    mListViewBarPtr = (ZKListView*)findControlByID(ID_STATUSBAR_ListViewBar);if(mListViewBarPtr!= NULL){mListViewBarPtr->setListAdapter(this);mListViewBarPtr->setItemClickListener(this);}
    mWinMenuPtr = (ZKWindow*)findControlByID(ID_STATUSBAR_WinMenu);
    mBurshRotationalPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_BurshRotational);
    mSpeedPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Speed);
    mlinePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_line);
    mspeedUnitPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_speedUnit);
    mWinSpeedPtr = (ZKWindow*)findControlByID(ID_STATUSBAR_WinSpeed);
    mTextLogoPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextLogo);
    mBottombgPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Bottombg);
    mshiningGearPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_shiningGear);
    mTextView3Ptr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextView3);
    mrangePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_range);
    moilIconPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_oilIcon);
    mWinFuelPtr = (ZKWindow*)findControlByID(ID_STATUSBAR_WinFuel);
    mTextView4Ptr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextView4);
    mtempIconPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_tempIcon);
    mWinCoolantPtr = (ZKWindow*)findControlByID(ID_STATUSBAR_WinCoolant);
    mgearPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_gear);
    mmileageTotalPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_mileageTotal);
    mgearRankPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_gearRank);
    mcompassPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_compass);
    mTextView1Ptr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextView1);
    mWD4LOWPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_WD4LOW);
    mECOPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_ECO);
    mdischargePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_discharge);
    mAUTOPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_AUTO);
    mSERVPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_SERV);
    mLOCKPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_LOCK);
    mNEUTRALPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_NEUTRAL);
    mOil_temperaturePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Oil_temperature);
    mbrakingPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_braking);
    mLow_oil_levePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Low_oil_leve);
    mGeneratorBatteryPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_GeneratorBattery);
    msteeringSystemPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_steeringSystem);
    mfailurePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_failure);
    mElectronic_throttlePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Electronic_throttle);
    mAutomaticPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Automatic);
    mTrailer_malfunctionPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Trailer_malfunction);
    mCleaning_liquidPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Cleaning_liquid);
    mascend_descendPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_ascend_descend);
    mFuel_tankPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Fuel_tank);
    mOIL_PRESSUREPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_OIL_PRESSURE);
    mAntifreezePtr = (ZKTextView*)findControlByID(ID_STATUSBAR_Antifreeze);
    mTextFaultPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextFault);
    mWinFaultPtr = (ZKWindow*)findControlByID(ID_STATUSBAR_WinFault);
    mTextDoorRRPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextDoorRR);
    mTextDoorRLPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextDoorRL);
    mTextDoorFRPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextDoorFR);
    mTextDoorFLPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_TextDoorFL);
    mCarDoorPtr = (ZKTextView*)findControlByID(ID_STATUSBAR_CarDoor);
    mWindowCarDoorPtr = (ZKWindow*)findControlByID(ID_STATUSBAR_WindowCarDoor);
	mstatusbarPtr = this;
	onUI_init();
    // 注册监听全局触摸
    EASYUICONTEXT->registerGlobalTouchListener(this);
    registerProtocolDataUpdateListener(onProtocolDataUpdate); 
    rigesterActivityTimer();
    startVideoLoopPlayback();
}

void statusbar::onClick(ZKBase *pBase) {
    int buttonTablen = sizeof(sButtonCallbackTab) / sizeof(S_ButtonCallback);
    for (int i = 0; i < buttonTablen; ++i) {
        if (sButtonCallbackTab[i].id == pBase->getID()) {
            if (sButtonCallbackTab[i].callback((ZKButton*)pBase)) {
            	return;
            }
            break;
        }
    }


    int len = sizeof(sAppInfoTab) / sizeof(sAppInfoTab[0]);
    for (int i = 0; i < len; ++i) {
        if (sAppInfoTab[i].id == pBase->getID()) {
            EASYUICONTEXT->openActivity(sAppInfoTab[i].pApp);
            return;
        }
    }

	BaseApp::onClick(pBase);
}

bool statusbar::onTimer(int id) {
    return onUI_Timer(id);
}


void statusbar::onProgressChanged(ZKSeekBar *pSeekBar, int progress){

    int seekBarTablen = sizeof(SZKSeekBarCallbackTab) / sizeof(S_ZKSeekBarCallback);
    for (int i = 0; i < seekBarTablen; ++i) {
        if (SZKSeekBarCallbackTab[i].id == pSeekBar->getID()) {
            SZKSeekBarCallbackTab[i].callback(pSeekBar, progress);
            break;
        }
    }
}

int statusbar::getListItemCount(const ZKListView *pListView) const{
    int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
            return SListViewFunctionsCallbackTab[i].getListItemCountCallback(pListView);
            break;
        }
    }
    return 0;
}
void statusbar::obtainListItemData(ZKListView *pListView,ZKListView::ZKListItem *pListItem, int index){
    int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
            SListViewFunctionsCallbackTab[i].obtainListItemDataCallback(pListView, pListItem, index);
            break;
        }
    }
}
void statusbar::onItemClick(ZKListView *pListView, int index, int id){
    int tablen = sizeof(SListViewFunctionsCallbackTab) / sizeof(S_ListViewFunctionsCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SListViewFunctionsCallbackTab[i].id == pListView->getID()) {
            SListViewFunctionsCallbackTab[i].onItemClickCallback(pListView, index, id);
            break;
        }
    }
}

void statusbar::onSlideItemClick(ZKSlideWindow *pSlideWindow, int index) {
    int tablen = sizeof(SSlideWindowItemClickCallbackTab) / sizeof(S_SlideWindowItemClickCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SSlideWindowItemClickCallbackTab[i].id == pSlideWindow->getID()) {
            SSlideWindowItemClickCallbackTab[i].onSlideItemClickCallback(pSlideWindow, index);
            break;
        }
    }
}

bool statusbar::onTouchEvent(const MotionEvent &ev) {
    return onstatusbarActivityTouchEvent(ev);
}

void statusbar::onTextChanged(ZKTextView *pTextView, const std::string &text) {
    int tablen = sizeof(SEditTextInputCallbackTab) / sizeof(S_EditTextInputCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SEditTextInputCallbackTab[i].id == pTextView->getID()) {
            SEditTextInputCallbackTab[i].onEditTextChangedCallback(text);
            break;
        }
    }
}

void statusbar::rigesterActivityTimer() {
    int tablen = sizeof(REGISTER_ACTIVITY_TIMER_TAB) / sizeof(S_ACTIVITY_TIMEER);
    for (int i = 0; i < tablen; ++i) {
        S_ACTIVITY_TIMEER temp = REGISTER_ACTIVITY_TIMER_TAB[i];
        registerTimer(temp.id, temp.time);
    }
}


void statusbar::onVideoPlayerMessage(ZKVideoView *pVideoView, int msg) {
    int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
    for (int i = 0; i < tablen; ++i) {
        if (SVideoViewCallbackTab[i].id == pVideoView->getID()) {
        	if (SVideoViewCallbackTab[i].loop) {
                //循环播放
        		videoLoopPlayback(pVideoView, msg, i);
        	} else if (SVideoViewCallbackTab[i].onVideoViewCallback != NULL){
        	    SVideoViewCallbackTab[i].onVideoViewCallback(pVideoView, msg);
        	}
            break;
        }
    }
}

void statusbar::videoLoopPlayback(ZKVideoView *pVideoView, int msg, size_t callbackTabIndex) {

	switch (msg) {
	case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED:
		LOGD("ZKVideoView::E_MSGTYPE_VIDEO_PLAY_STARTED\n");
    if (callbackTabIndex >= (sizeof(SVideoViewCallbackTab)/sizeof(S_VideoViewCallback))) {
      break;
    }
		pVideoView->setVolume(SVideoViewCallbackTab[callbackTabIndex].defaultvolume / 10.0);
		mVideoLoopErrorCount = 0;
		break;
	case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_ERROR:
		/**错误处理 */
		++mVideoLoopErrorCount;
		if (mVideoLoopErrorCount > 100) {
			LOGD("video loop error counts > 100, quit loop playback !");
            break;
		} //不用break, 继续尝试播放下一个
	case ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED:
		LOGD("ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED\n");
        std::vector<std::string> videolist;
        std::string fileName(getAppName());
        if (fileName.size() < 4) {
             LOGD("getAppName size < 4, ignore!");
             break;
        }
        fileName = fileName.substr(0, fileName.length() - 4) + "_video_list.txt";
        fileName = "/mnt/extsd/" + fileName;
        if (!parseVideoFileList(fileName.c_str(), videolist)) {
            LOGD("parseVideoFileList failed !");
		    break;
        }
		if (pVideoView && !videolist.empty()) {
			mVideoLoopIndex = (mVideoLoopIndex + 1) % videolist.size();
			pVideoView->play(videolist[mVideoLoopIndex].c_str());
		}
		break;
	}
}

void statusbar::startVideoLoopPlayback() {
    int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
    for (int i = 0; i < tablen; ++i) {
    	if (SVideoViewCallbackTab[i].loop) {
    		ZKVideoView* videoView = (ZKVideoView*)findControlByID(SVideoViewCallbackTab[i].id);
    		if (!videoView) {
    			return;
    		}
    		//循环播放
    		videoLoopPlayback(videoView, ZKVideoView::E_MSGTYPE_VIDEO_PLAY_COMPLETED, i);
    		return;
    	}
    }
}

void statusbar::stopVideoLoopPlayback() {
    int tablen = sizeof(SVideoViewCallbackTab) / sizeof(S_VideoViewCallback);
    for (int i = 0; i < tablen; ++i) {
    	if (SVideoViewCallbackTab[i].loop) {
    		ZKVideoView* videoView = (ZKVideoView*)findControlByID(SVideoViewCallbackTab[i].id);
    		if (!videoView) {
    			return;
    		}
    		if (videoView->isPlaying()) {
    		    videoView->stop();
    		}
    		return;
    	}
    }
}

bool statusbar::parseVideoFileList(const char *pFileListPath, std::vector<string>& mediaFileList) {
	mediaFileList.clear();
	if (NULL == pFileListPath || 0 == strlen(pFileListPath)) {
        LOGD("video file list is null!");
		return false;
	}

	ifstream is(pFileListPath, ios_base::in);
	if (!is.is_open()) {
		LOGD("cann't open file %s \n", pFileListPath);
		return false;
	}
	char tmp[1024] = {0};
	while (is.getline(tmp, sizeof(tmp))) {
		string str = tmp;
		removeCharFromString(str, '\"');
		removeCharFromString(str, '\r');
		removeCharFromString(str, '\n');
		if (str.size() > 1) {
     		mediaFileList.push_back(str.c_str());
		}
	}
	LOGD("(f:%s, l:%d) parse fileList[%s], get [%d]files\n", __FUNCTION__,
			__LINE__, pFileListPath, mediaFileList.size());
	for (size_t i = 0; i < mediaFileList.size(); i++) {
		LOGD("file[%d]:[%s]\n", i, mediaFileList[i].c_str());
	}
	is.close();

	return true;
}

int statusbar::removeCharFromString(string& nString, char c)
{
    string::size_type   pos;
    while(1) {
        pos = nString.find(c);
        if(pos != string::npos) {
            nString.erase(pos, 1);
        } else {
            break;
        }
    }
    return (int)nString.size();
}

void statusbar::registerUserTimer(int id, int time) {
	registerTimer(id, time);
}

void statusbar::unregisterUserTimer(int id) {
	unregisterTimer(id);
}

void statusbar::resetUserTimer(int id, int time) {
	resetTimer(id, time);
}